import axios from 'axios';
import {failedNotify, successNotify} from '@/comm/index.js'

export function fetchTcList(payload, callback, callError) {
  axios 
      .post('/payload/tc/cmdlist', payload)
      .then(response => {
        callback(response)
      })
      .catch(error => {
        callError(error)
      });
}

export function fetchNavigateList(data, callback, callError) {
  axios 
      .post('/payload/tm/navigatelist', data)
      .then(response => {
        callback(response)
      })
      .catch(error => {
        callError(error)
      });
}

export function setTcCmd(data, callback, callError) {
  axios 
      .post('/payload/tc/cmdresult', data)
      .then(response => {
        callback(response)
      })
      .catch(error => {
        callError(error)
      });
}

export function addUtm(data, callback, callError) {
  axios 
      .post('/payload/tm/udladd', data)
      .then(response => {
        callback(response)
      })
      .catch(error => {
        callError(error)
      });
}

export function delUtm(data, callback, callError) {
  axios 
      .post('/payload/tm/udldel', data)
      .then(response => {
        callback(response)
      })
      .catch(error => {
        failedNotify("操作失败! ", error)
        callError(error)
      });
}

export function getUtm(callback, callError) {
  axios 
      .post('/payload/tm/udlget')
      .then(response => {
        callback(response.data)
      })
      .catch(error => {
        callError(error)
      });
}

export function fetchSlowTmList(data, callback, callError) {
  axios 
      .post('/payload/tm/slowlist', data)
      .then(response => {
        callback(response.data)
      })
      .catch(error => {
        callError(error)
      });
}

export function fetchAllTmList(data, callback, callError) {
    axios
        .post('/payload/tm/tmlist', data)
        .then(response => {
            callback(response.data)
        })
        .catch(error => {
            callError(error)
        });
}

